package com.gopay.common.util;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class JavaScriptUtil {
	
	public static String escape(String str) throws Exception {
		ScriptEngineManager sem = new ScriptEngineManager();

		ScriptEngine engine = sem.getEngineByExtension("js");
		
		String escape = (String) engine.eval(" escape('"+str+"')");
		return escape;
	}
	
	public static String unescape(String unstr) throws Exception{
		ScriptEngineManager unsem = new ScriptEngineManager();

		ScriptEngine unengine = unsem.getEngineByExtension("js");
		
		String unescape= (String) unengine.eval(" unescape('"+unstr+"')");
		return unescape;
	}
	
	public static void main(String[] args) throws Exception {
		System.out.println(unescape("%u767E%u5EA6%u94B1%u5305"));
	}
	
}
